<?php

use yii\grid\GridView;
use common\helpers\Html;
use yii\helpers\Url;

$this->title = '等级管理';
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">
                    <?= $this->title; ?>
                    <small></small>
                </h3>
                <div class="box-tools">
                    <?= Html::create(['edit','sid'=>$user_id], '等级管理') ?>
                </div>
            </div>
            <div class="box-body table-responsive">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    // 重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                        ],
                        [
                            'attribute' => 'cate.name',
                        ],
                       'grade',
                       'content',
                        [
                            'attribute' => 'created_at',
                            'label' => '添加时间',
                            'format' =>['date', 'php:Y-m-d H:i:s'],
                            'headerOptions' => ['class' => 'col-md-1 text-center'],
                            'contentOptions' => ['class' => 'text-center'],
                        ],
                        [
                            'attribute' => 'updated_at',
                            'label' => '修改时间',
                            'format' =>['date', 'php:Y-m-d H:i:s'],
                            'headerOptions' => ['class' => 'col-md-1 text-center'],
                            'contentOptions' => ['class' => 'text-center'],
                        ],
                        [
                            'header' => "操作",
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{ajax-edit} {status} {destroy}',
                            'buttons' => [
                                'ajax-edit' => function ($url, $model, $key) use($user_id) {
                                    return Html::edit(['ajax-edit', 'id' => $model->id,'sid'=>$user_id], '编辑', [
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                },
                                'status' => function ($url, $model, $key) {
                                    return Html::status($model->status);
                                },
                                'destroy' => function ($url, $model, $key) {
                                    return Html::delete(['destroy', 'id' => $model->id]);
                                },
                            ],
                        ],
                    ],
                ]); ?>
            </div>
        </div>
    </div>